package Json2RDF.Json2Java.OntologyClasses;

import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.jena.rdf.model.Property;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * {@code Face}类表示一个表面实例.
 * 提供表面的id、所属零件的id以及和其他表面的关系列表.
 * 其他表面类继承该类.
 */
public abstract class Face {
  protected Map<Face, List<Property>> relations;
  @JsonProperty("ID")
  protected String id;
  @JsonProperty("PartID")
  protected String partId;

  public Face() {
    this.id = "";
    this.partId = "";
    this.relations = new HashMap<Face, List<Property>>();
  }

  public String getId() {
    return id;
  }

  public void setId(String id) {
    this.id = id;
  }

  public String getPartId() {
    return partId;
  }

  public void setPartId(String partId) {
    this.partId = partId;
  }

  public Map<Face, List<Property>> getRelations() {
    return relations;
  }

  public void addRelation(Face string, Property property) {
    relations.computeIfAbsent(string, k -> new ArrayList<>()).add(property);
  }

  public void addRelation(Face string, List<Property> properties) {
    relations.computeIfAbsent(string, k -> new ArrayList<>()).addAll(properties);
  }
}
